package com.huijiet.base.common;

public class Ref {

    /**请求成功,无返回值*/
    public static CommonResult<Void> ok(){
        CommonResult<Void> result = new CommonResult<>();
        result.setCode(0);
        result.setData(null);
        result.setMsg("成功");
        return result;
    }

    /**请求成功,有返回值T*/
    public static <T> CommonResult<T> ok(T o){
        CommonResult<T> result = new CommonResult<>();
        result.setCode(0);
        result.setData(o);
        result.setMsg("成功");
        return result;
    }

    /**请求成功,没有返回值,有成功提示*/
    public static CommonResult<Void> okMsg(String msg){
        CommonResult<Void> result = new CommonResult<>();
        result.setCode(0);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }

    /**请求成功,有返回值T和成功提示*/
    public static <T> CommonResult<T> okMsg(T o, String msg){
        CommonResult<T> result = new CommonResult<>();
        result.setCode(0);
        result.setData(o);
        result.setMsg(msg);
        return result;
    }

    /**请求失败,业务逻辑错误*/
    public static <T> CommonResult<T> error(String errMsg){
        CommonResult<T> result = new CommonResult<>();
        result.setCode(3001);
        result.setData(null);
        result.setMsg(errMsg);
        return result;
    }
}
